<?php

class Set_captcha_model extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    function setCaptcha() {
        $this->CI = get_instance();
        $vals = array(
            'img_path' => base_url().'/captcha/',
            'img_url' => site_url() . '/captcha/',
            'font_path' => base_url(). '/system/fonts/texb.ttf',
            'expiration' => 3600,
            'img_width'=> '140',
            'img_heigth'=> 30,
            'word'=>  random_string('numeric',6),
        );
        $cap = create_captcha($vals);
        if($cap){
            $capdb = array(
                'captcha_id' => '',
                'captcha_time' => $cap['time'],
                'ip_address' => $this->CI->input->ip_address(),
                'word' => $cap['word']
            );
            $query = $this->insert_string('captcha',$capdb);
            $this->db->query($query);
        }else{
            return 'capcha khong lam viec';
        }
        return $cap['image'];
    }
}

?>
